<?php
header('content-type:text/html;charset=utf-8');
session_start();
$_SESSION['uid'] = 'zhangsan';
$money = $_POST['pay'];
$payer = $_SESSION['uid'];
$towho = $_POST['towho'];
$pdo = new PDO("mysql:host=127.0.0.1;dbname=zgr","root","root");
$pdo->beginTransaction();
$select = $pdo->query("select * from lx7_4 where uid = '$payer' ")->fetch();
$nums1 = $pdo->exec("update lx7_4 set money = money-'$money' where uid = '$payer'  ");
$nums2 = $pdo->exec("update lx7_4 set money = money+'$money' where uid = '$towho'  ");
if($nums1>0 && $nums2>0 && $select['money']>=$money)
{
    $pdo->commit();
}
else
{
    $pdo->rollBack();
}




?>






